<template>
	<view class="content">
		<view class="info-content">
			<template v-if="suzhou.length>0">
				<view class="title-item">
					<view class="line"></view>
					<view class="title FangZhengHanZhenGuangBiaoJianTi">肃州区</view>
				</view>
				<view class="info-block">
					<view class="info-list" v-for="(item, index) in suzhou" :key="item.id"
						@click="navigate('/page_other/job_hunting/job_list/index?type=1&name=找全职&id=' + item.id)">
						<view :class="['info-item', getColorClass(index)]">
							<view class="title">{{ item.name }}</view>
							<view class="arrow-item">
								<view class="count">{{ item.count }}个</view>
								<view class="circular">
									<view class="arrow">→</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</template>
			<template v-if="jinta.length>0">
				<view class="title-item">
					<view class="line"></view>
					<view class="title FangZhengHanZhenGuangBiaoJianTi">金塔县</view>
				</view>
				<view class="info-block">
					<view class="info-list" v-for="(item, index) in jinta" :key="item.id"
						@click="navigate('/page_other/job_hunting/job_list/index?type=1&name=找全职&id=' + item.id)">
						<view :class="['info-item', getColorClass(index)]">
							<view class="title">{{ item.name }}</view>
							<view class="arrow-item">
								<view class="count">{{ item.count }}个</view>
								<view class="circular">
									<view class="arrow">→</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</template>
			<template v-if="dunhang.length>0">
				<view class="title-item">
					<view class="line"></view>
					<view class="title FangZhengHanZhenGuangBiaoJianTi">敦煌市</view>
				</view>
				<view class="info-block">
					<view class="info-list" v-for="(item, index) in dunhang" :key="item.id"
						@click="navigate('/page_other/job_hunting/job_list/index?type=1&name=找全职&id=' + item.id)">
						<view :class="['info-item', getColorClass(index)]">
							<view class="title">{{ item.name }}</view>
							<view class="arrow-item">
								<view class="count">{{ item.count }}个</view>
								<view class="circular">
									<view class="arrow">→</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</template>
			<template v-if="yumen.length>0">
				<view class="title-item">
					<view class="line"></view>
					<view class="title FangZhengHanZhenGuangBiaoJianTi">玉门市</view>
				</view>
				<view class="info-block">
					<view class="info-list" v-for="(item, index) in yumen" :key="item.id"
						@click="navigate('/page_other/job_hunting/job_list/index?type=1&name=找全职&id=' + item.id)">
						<view :class="['info-item', getColorClass(index)]">
							<view class="title">{{ item.name }}</view>
							<view class="arrow-item">
								<view class="count">{{ item.count }}个</view>
								<view class="circular">
									<view class="arrow">→</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</template>
			<template v-if="guazhou.length>0">
				<view class="title-item">
					<view class="line"></view>
					<view class="title FangZhengHanZhenGuangBiaoJianTi">瓜州县</view>
				</view>
				<view class="info-block">
					<view class="info-list" v-for="(item, index) in guazhou" :key="item.id"
						@click="navigate('/page_other/job_hunting/job_list/index?type=1&name=找全职&id=' + item.id)">
						<view :class="['info-item', getColorClass(index)]">
							<view class="title">{{ item.name }}</view>
							<view class="arrow-item">
								<view class="count">{{ item.count }}个</view>
								<view class="circular">
									<view class="arrow">→</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</template>
			<template v-if="subei.length>0">
				<view class="title-item">
					<view class="line"></view>
					<view class="title FangZhengHanZhenGuangBiaoJianTi">肃北县</view>
				</view>
				<view class="info-block">
					<view class="info-list" v-for="(item, index) in subei" :key="item.id"
						@click="navigate('/page_other/job_hunting/job_list/index?type=1&name=找全职&id=' + item.id)">
						<view :class="['info-item', getColorClass(index)]">
							<view class="title">{{ item.name }}</view>
							<view class="arrow-item">
								<view class="count">{{ item.count }}个</view>
								<view class="circular">
									<view class="arrow">→</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</template>
			<template v-if="akesai.length>0">
				<view class="title-item">
					<view class="line"></view>
					<view class="title FangZhengHanZhenGuangBiaoJianTi">阿克塞县</view>
				</view>
				<view class="info-block">
					<view class="info-list" v-for="(item, index) in akesai" :key="item.id"
						@click="navigate('/page_other/job_hunting/job_list/index?type=1&name=找全职&id=' + item.id)">
						<view :class="['info-item', getColorClass(index)]">
							<view class="title">{{ item.name }}</view>
							<view class="arrow-item">
								<view class="count">{{ item.count }}个</view>
								<view class="circular">
									<view class="arrow">→</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</template>
		</view>
	</view>
</template>

<script>
	import {
		getStreetListApi
	} from '@/api/accept.js'
	import {
		getStorage
	} from '@/util/auth'

	export default {
		data() {
			return {
				akesai: [],
				dunhang: [],
				guazhou: [],
				jinta: [],
				subei: [],
				suzhou: [],
				yumen: [],
				type: 0
			}
		},
		methods: {
			navigate(url) {
				uni.navigateTo({
					url
				})
			},
			getList() {
				uni.showLoading({
					title: '加载中'
				})
				getStreetListApi({
					type: this.type
				}).then((res) => {
					this.suzhou = res.suzhou ?? [];
					this.jinta = res.jinta ?? [];
					this.guazhou = res.guazhou ?? [];
					this.yumen = res.yumen ?? [];
					this.dunhang = res.dunhang ?? [];
					this.subei = res.subei ?? [];
					this.akesai = res.akesai ?? [];

				})
			},
			getColorClass(index) {
				const colors = ['bg-green', 'bg-pink', 'bg-yellow', 'bg-blue'];
				return colors[index % colors.length];
			}
		},
		onLoad() {
			const area = getStorage('area');
			this.type = area.value;
			this.getList();
		}
	}
</script>

<style lang="scss">
	.content {
		width: 100%;
		background: #fff;
		min-height: 100vh;
		padding: 30rpx;

		.info-content {
			.title-item {
				display: flex;
				align-items: center;
				margin-bottom: 30rpx;

				.line {
					width: 8rpx;
					height: 40rpx;
					border-radius: 60rpx;
					background: linear-gradient(to bottom, #fff, #0256FF, #fff);
					margin-right: 20rpx;
				}

				.title {
					font-size: 34rpx;
					color: #0256FF;
				}
			}
		}

		.info-block {
			display: flex;
			flex-direction: row;
			flex-wrap: wrap;



			.info-list {
				width: calc(100% / 3);

				.info-item {
					margin-right: 20rpx;
					height: 200rpx;
					display: flex;
					flex-direction: column;
					margin-bottom: 20rpx;
					border-radius: 20rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					padding: 30rpx;

					.title {
						font-size: 30rpx;
					}

					.arrow-item {
						width: 100%;
						display: flex;
						justify-content: space-between;
						margin-top: 40rpx;
						align-items: center;

						.count {
							color: #0256FF;
						}

						.circular {
							width: 36rpx;
							height: 36rpx;
							border-radius: 50%;
							border: 1px solid #0256FF;
							text-align: center;

							.arrow {
								font-size: 24rpx;
								color: #0256FF;
								font-weight: bold;
							}
						}
					}
				}
			}
		}
	}

	/* Define background colors as classes */
	.bg-green {
		background-color: #EAFAED;
	}

	.bg-pink {
		background-color: #FFF5F4;
	}

	.bg-yellow {
		background-color: #FEF7ED;
	}

	.bg-blue {
		background-color: #EBFAFF;
	}
</style>